var _util = require('util/util.js');

var _evaluation_service = {
    getComments: function(itemid, resolve, reject){
        _util.sync_request({
            url: _util.getServerURL('/evaluation/items/' + itemid),
            method: "GET",
            success: resolve,
            error: reject
        });
    },
    postComment: function(itemid, comment, star, resolve, reject){
        _util.request({
            url: _util.getServerURL('/evaluation/items/'+ itemid),
            method: "POST",
            success: resolve,
            error: reject,
            data: {
                content: comment,
                star: star
            }
        });
    },
    getFavouriteProducts: function(pageSize, pageid, resolve, reject) {
        _util.sync_request({
            url: _util.getServerURL('/evaluation/collections/pages/' + pageSize +'/' + pageid),
            method: "GET",
            success: resolve,
            error: reject
        });
    },
    likeProduct: function(itemid, resolve, reject){
        _util.request({
            url: _util.getServerURL('/evaluation/collections/items/' + itemid),
            method: "POST",
            success: resolve,
            error: reject
        });
    },
    unlikeProduct: function(itemid, resolve, reject){
        _util.request({
            url: _util.getServerURL('/evaluation/collections/items/' + itemid),
            method: "DELETE",
            success: resolve,
            error: reject
        });
    },
}

module.exports = _evaluation_service;